import axios from './axios';
import { proList, login, hot, searchList, detail, recommendlist, cartList, add, selectone, selectall, updatenum, del, addressList, defaultAddress, docheckphone, dosendmsgcode, docheckcode, dofinishregister, addressAdd, seckilllist, addressEdit } from './api';

// 地址修改
export function AddressEdit(data){
    return axios(addressEdit,{
        method:'post',
        data
    })
}

// 显示秒杀
export function Seckilllist(){
    return axios(seckilllist)
}

// 地址添加
export function AddressAdd(data){
    return axios(addressAdd,{
        method:'post',
        data
    })
}

// 注册 密码
export function Dofinishregister(data){
    return axios(dofinishregister,{
        method:'post',
        data
    })
}

//注册 验证码
export function Docheckcode(data){
    return axios(docheckcode,{
        method:'post',
        data
    })
} 

// 验证码
export function Dosendmsgcode(data){
    return axios(dosendmsgcode,{
        method:'post',
        data
    })
}

// 注册 电话
export function Docheckphone(data){
    // console.log(data);
    return axios(docheckphone,{
        method:'post',
        data
    })
}

// 默认地址
export function DefaultAddress(data){
    return axios(defaultAddress,{
        method:'post',
        data
    })
}

// 地址列表
export function AddressList(userid){
    return axios(addressList+userid)
}

// 购物车删除
export function DEL(data){
    return axios(del,{
        method:'post',
        data
    })
}

// 更新购物车数量
export function Updatenum(data){
    if(data.num < 1 ) {
        data.num=1
    }
    return axios(updatenum,{
        method:'post',
        data
    })
}

// 更新所有购物车状态
export function Selectall(data){
    return axios(selectall,{
        method:'post',
        data
    })
}

// 购物车状态
export function Selectone(data){
    return axios(selectone,{
        method:'post',
        data
    })
}

//  添加商品
export function ADD(data){
    return axios(add,{
        method:'post',
        data
    })
}

// 购物车列表
export function CarList(data){
    return axios(cartList,{
        method:'post',
        data
    })
}

// 购物车推荐
export function Recommendlist(){
    return axios(recommendlist)
}

// 详情
export function DETAIL(id){
    return axios(detail+id)
}

// 搜索列表
export function Searchlist(data){
    return axios(searchList+data.page+'&keyword='+data.keyword)
}

// 热门搜索
export function Hot(){
    return axios(hot)
}

// 登录
export function LogiN(data){
    return axios(login,{
        method:'post',
        data
    })
}

// 商品列表
export function ProList(page){
    return axios(proList+'?count='+page)
}